/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JInternalFrameEmployee.java
 *
 * Created on Dec 7, 2011, 7:08:31 PM
 */
package bugreportingsystem;

import Util.*;
import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

/**
 *
 * @author Jack
 */
public class JInternalFrameEmployee extends javax.swing.JInternalFrame {

    private int iddepart;
    Vector<Integer> valueRl = new Vector<Integer>();
    Vector<String> displayRl = new Vector<String>();
    Employee ep = new Employee();
    int r = -1;
    int idem;
    private String language = JFrameLogin.language;
    private String country = JFrameLogin.country;
    private Locale lc = new Locale(language, country);
    private ResourceBundle rb = ResourceBundle.getBundle("bugreportingsystem/resources/JInternalFrameEmployee", lc);

    /** Creates new form JInternalFrameEmployee */
    public JInternalFrameEmployee() {
        initComponents();
        AddYear();
        AddND();
        DisplayTable(Employee.ListIDE());
        MyTranslate();
    }

    private TitledBorder SetTitleBorder(String a) {
        Border etched = BorderFactory.createEtchedBorder();
        Font font = new Font("Tahoma", Font.BOLD, 14);
        TitledBorder Title = BorderFactory.createTitledBorder(etched, rb.getString(a));
        Title.setTitleJustification(TitledBorder.LEFT);
        Title.setTitleFont(font);
        Title.setTitleColor(Color.getColor("BLUE", 204));
        return Title;
    }

    private void MyTranslate() {
        lblId.setText(rb.getString("lblId.text"));
        JRadioButtonID.setText(rb.getString("JRadioButtonID.text"));
        jRadioButtonName.setText(rb.getString("jRadioButtonName.text"));
        jRadioButtonDepart.setText(rb.getString("jRadioButtonDepart.text"));
        jButtonSearch.setText(rb.getString("jButtonSearch.text"));
        jButtonReset.setText(rb.getString("jButtonReset.text"));
        lblName.setText(rb.getString("lblName.text"));
        lblAddress.setText(rb.getString("lblAddress.text"));
        lblPhone.setText(rb.getString("lblPhone.text"));
        jLabel5.setText(rb.getString("jLabel5.text"));
        lblStatus.setText(rb.getString("lblStatus.text"));
        lblUsername.setText(rb.getString("lblUsername.text"));
        jLabel8.setText(rb.getString("jLabel8.text"));
        lblEmail.setText(rb.getString("lblEmail.text"));
        lblStaff.setText(rb.getString("lblStaff.text"));
        btnAdd.setText(rb.getString("btnAdd.text"));
        btnUpdate.setText(rb.getString("btnUpdate.text"));
        btnDelete.setText(rb.getString("btnDelete.text"));
        btnDelete1.setText(rb.getString("btnDelete1.text"));
        jPanel7.setBorder(SetTitleBorder("jPanel7.border.title"));
        jPanel17.setBorder(SetTitleBorder("jPanel17.border.title"));
        this.setTitle(rb.getString("Form.title"));
    }

    private void AddND() {
        Department rl = new Department();
        Vector<Department> vrl = new Vector<Department>();
        vrl = rl.ListIDD();
        for (Department i : vrl) {
            displayRl.add(i.getNamedepartment());
            valueRl.add(i.getIddepartment());
        }
        DefaultComboBoxModel dcb1 = new DefaultComboBoxModel(displayRl);
        jComboBoxDepart.setModel(dcb1);
    }

    private void AddYear() {
        try {
            Vector<String> year = new Vector<String>();
            for (int i = 1980; i < 2013; i++) {
                year.add(String.valueOf(i));
            }
            DefaultComboBoxModel dcb = new DefaultComboBoxModel(year);
            this.jComboBoxNam.setModel(dcb);


        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public static String convertPassword(char[] cPassword) {
        // Declare variables
        String strRet = new String("");

        // Go through each character
        for (int i = 0; i < cPassword.length; i++) {
            strRet += cPassword[i];
        }

        return strRet;
    }

    private void DisplayTable(Vector<Employee> ep1) {
        Vector<String> cols = new Vector<String>();
        cols.add("idemployee");
        cols.add("Name");
        cols.add("username");
        cols.add("Sex");
        cols.add("Address");
        cols.add("email");
        cols.add("Phone");
        cols.add("BirthDay");
        cols.add("Department");
        Employee ep = new Employee();
        Vector<Vector<Object>> rows = new Vector<Vector<Object>>();
        for (int i = 0; i < ep1.size(); i++) {
            Vector<Object> i1 = new Vector<Object>();
            String namerl = ep1.get(i).ListRole(ep1.get(i).getIdemployee());
            i1.add(ep1.get(i).getIdemployee());
            i1.add(ep1.get(i).getNameemployee());
            i1.add(ep1.get(i).getUsername());
            i1.add(ep1.get(i).getSex());
            i1.add(ep1.get(i).getHomeaddress());
            i1.add(ep1.get(i).getEmailaddress());
            i1.add(ep1.get(i).getPhonenumber());
            i1.add(ep1.get(i).getBirthday());
            i1.add(namerl);
            rows.add(i1);
        }
        DefaultTableModel dtm = new DefaultTableModel(rows, cols) {

            @Override
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        this.jTable1.setModel(dtm);
        this.jTable1.getTableHeader().setReorderingAllowed(false);
    }

    private void DisplayTableNull() {
        Vector<String> cols = new Vector<String>();
        cols.add("idemployee");
        cols.add("Name");
        cols.add("username");
        cols.add("Sex");
        cols.add("Address");
        cols.add("email");
        cols.add("Phone");
        cols.add("BirthDay");
        cols.add("Department");
        Employee ep = new Employee();
        Vector<Vector<Object>> rows = new Vector<Vector<Object>>();
        DefaultTableModel dtm = new DefaultTableModel(rows, cols) {

            @Override
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        this.jTable1.setModel(dtm);
        this.jTable1.getTableHeader().setReorderingAllowed(false);
    }

    private int CanculateAge() {
        int tuoi = 0;

        try {
            String birthday = this.jComboBoxNam.getSelectedItem().toString() + "-" + this.jComboBoxThang.getSelectedItem().toString() + "-" + this.jComboBoxngay.getSelectedItem().toString();

            SimpleDateFormat spf = new SimpleDateFormat("yyyy-MM-dd");
            spf.setLenient(false);
            Date ngaysinh = spf.parse(birthday);
            Date ngayhientai = new Date();
            Calendar c1 = Calendar.getInstance();
            c1.setTime(ngaysinh);
            Calendar c2 = Calendar.getInstance();
            c2.setTime(ngayhientai);
            tuoi = Math.abs(c1.get(Calendar.YEAR) - c2.get(Calendar.YEAR));
        } catch (Exception ex) {
        }

        return tuoi;
    }

    private boolean CheckDate() {
        boolean kq = true;

        try {
            String birthday = this.jComboBoxNam.getSelectedItem().toString() + "-" + this.jComboBoxThang.getSelectedItem().toString() + "-" + this.jComboBoxngay.getSelectedItem().toString();

            SimpleDateFormat spf = new SimpleDateFormat("yyyy-MM-dd");
            spf.setLenient(false);
            Date ngaysinh = spf.parse(birthday);
            Calendar c1 = Calendar.getInstance();
            c1.setTime(ngaysinh);

        } catch (Exception ex) {
            return false;
        }

        return kq;
    }

    private void Display() {
        r = this.jTable1.getSelectedRow();
        idem = Integer.parseInt(this.jTable1.getValueAt(r, 0).toString());
        //Sidem=Integer.parseInt(this.jTable1.getValueAt(r,0).toString());
        String name = this.jTable1.getValueAt(r, 1).toString();
        String username = this.jTable1.getValueAt(r, 2).toString();
        String sex = this.jTable1.getValueAt(r, 3).toString();
        String address = this.jTable1.getValueAt(r, 4).toString();
        String email = this.jTable1.getValueAt(r, 5).toString();
        String phone = this.jTable1.getValueAt(r, 6).toString().trim();
        String department = this.jTable1.getValueAt(r, 8).toString();
        iddepart = Employee.ListIDE().get(r).getIddepartment();

        String birthday = this.jTable1.getValueAt(r, 7).toString();
        String[] a = birthday.split("-");
        String day = a[2];
        String month = a[1];
        String year = a[0];
        if (iddepart == 1) {
            jComboBoxDepart.setEnabled(false);
            jPasswordFieldPassword.setEnabled(false);
        } else {
            jComboBoxDepart.setEnabled(true);
            jPasswordFieldPassword.setEnabled(true);
        }
        this.jComboBoxngay.setSelectedItem(day);
        this.jComboBoxThang.setSelectedItem(month);
        this.jComboBoxNam.setSelectedItem(year);
        this.jTextFieldName.setText(name);
        this.jTextFieldUserName.setText(username);
        this.jTextFieldID.setText(String.valueOf(idem));
        this.jTextFieldAddress.setText(address);
        this.jTextFieldEmail.setText(email);
        this.jTextFieldPhone.setText(phone);
        this.jComboBoxSex.setSelectedItem(sex);
        this.jComboBoxDepart.setSelectedItem(department);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        jButtonSearch = new javax.swing.JButton();
        jPanel12 = new javax.swing.JPanel();
        JTextFieldSearch = new javax.swing.JTextField();
        jPanel10 = new javax.swing.JPanel();
        jPanel13 = new javax.swing.JPanel();
        JRadioButtonID = new javax.swing.JRadioButton();
        jPanel14 = new javax.swing.JPanel();
        jPanel15 = new javax.swing.JPanel();
        jRadioButtonName = new javax.swing.JRadioButton();
        jPanel16 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jRadioButtonDepart = new javax.swing.JRadioButton();
        jPanel28 = new javax.swing.JPanel();
        jPanel29 = new javax.swing.JPanel();
        jLabelNamDepartment = new javax.swing.JLabel();
        jPanel30 = new javax.swing.JPanel();
        jButtonReset = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jPanel17 = new javax.swing.JPanel();
        jPanel21 = new javax.swing.JPanel();
        jPanel22 = new javax.swing.JPanel();
        jPanel23 = new javax.swing.JPanel();
        jPanel24 = new javax.swing.JPanel();
        jPanel25 = new javax.swing.JPanel();
        jPanel_____Left = new javax.swing.JPanel();
        jPanel33 = new javax.swing.JPanel();
        lblId = new javax.swing.JLabel();
        q = new javax.swing.JLabel();
        lblName = new javax.swing.JLabel();
        w = new javax.swing.JLabel();
        lblAddress = new javax.swing.JLabel();
        e = new javax.swing.JLabel();
        lblPhone = new javax.swing.JLabel();
        v = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jPanel34 = new javax.swing.JPanel();
        jTextFieldID = new javax.swing.JTextField();
        l = new javax.swing.JLabel();
        jTextFieldName = new javax.swing.JTextField();
        jLabelName = new javax.swing.JLabel();
        jTextFieldAddress = new javax.swing.JTextField();
        jLabelAdress = new javax.swing.JLabel();
        jTextFieldPhone = new javax.swing.JTextField();
        jLabelPhone = new javax.swing.JLabel();
        jPanel35 = new javax.swing.JPanel();
        jPanel36 = new javax.swing.JPanel();
        jComboBoxSex = new javax.swing.JComboBox();
        jPanel37 = new javax.swing.JPanel();
        jPanel40 = new javax.swing.JPanel();
        jPanel______Right = new javax.swing.JPanel();
        jPanel27 = new javax.swing.JPanel();
        jPanel38 = new javax.swing.JPanel();
        jPanel39 = new javax.swing.JPanel();
        lblStatus = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        lblUsername = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        lblEmail = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        lblStaff = new javax.swing.JLabel();
        jPanel41 = new javax.swing.JPanel();
        jPanel42 = new javax.swing.JPanel();
        jComboBoxngay = new javax.swing.JComboBox();
        jComboBoxThang = new javax.swing.JComboBox();
        jComboBoxNam = new javax.swing.JComboBox();
        jLabelBrithday = new javax.swing.JLabel();
        jTextFieldUserName = new javax.swing.JTextField();
        jLabelUsername = new javax.swing.JLabel();
        jPasswordFieldPassword = new javax.swing.JPasswordField();
        jLabelPassword = new javax.swing.JLabel();
        jTextFieldEmail = new javax.swing.JTextField();
        jLabelEmail = new javax.swing.JLabel();
        jComboBoxDepart = new javax.swing.JComboBox();
        jPanel45 = new javax.swing.JPanel();
        jPanel32 = new javax.swing.JPanel();
        btnAdd = new javax.swing.JButton();
        btnUpdate = new javax.swing.JButton();
        btnDelete = new javax.swing.JButton();
        btnDelete1 = new javax.swing.JButton();
        jPanel19 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(bugreportingsystem.BugReportingSystemApp.class).getContext().getResourceMap(JInternalFrameEmployee.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
        setMinimumSize(new java.awt.Dimension(1005, 595));
        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(1018, 607));

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new java.awt.BorderLayout());

        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setPreferredSize(new java.awt.Dimension(853, 300));
        jPanel3.setLayout(new java.awt.BorderLayout(0, 5));

        jPanel5.setName("jPanel5"); // NOI18N
        jPanel5.setPreferredSize(new java.awt.Dimension(853, 90));
        jPanel5.setLayout(new java.awt.BorderLayout());

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel7.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel7.border.titleFont"), resourceMap.getColor("jPanel7.border.titleColor"))); // NOI18N
        jPanel7.setName("jPanel7"); // NOI18N
        jPanel7.setPreferredSize(new java.awt.Dimension(420, 130));
        jPanel7.setLayout(new java.awt.GridLayout(2, 1, 0, 5));

        jPanel9.setName("jPanel9"); // NOI18N
        jPanel9.setLayout(new java.awt.BorderLayout(10, 0));

        jPanel11.setMinimumSize(new java.awt.Dimension(40, 40));
        jPanel11.setName("jPanel11"); // NOI18N
        jPanel11.setPreferredSize(new java.awt.Dimension(119, 40));
        jPanel11.setLayout(new java.awt.BorderLayout());

        jButtonSearch.setIcon(resourceMap.getIcon("jButtonSearch.icon")); // NOI18N
        jButtonSearch.setText(resourceMap.getString("jButtonSearch.text")); // NOI18N
        jButtonSearch.setName("jButtonSearch"); // NOI18N
        jButtonSearch.setPreferredSize(new java.awt.Dimension(100, 33));
        jButtonSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSearchActionPerformed(evt);
            }
        });
        jPanel11.add(jButtonSearch, java.awt.BorderLayout.CENTER);

        jPanel9.add(jPanel11, java.awt.BorderLayout.LINE_END);

        jPanel12.setName("jPanel12"); // NOI18N
        jPanel12.setLayout(new java.awt.BorderLayout());

        JTextFieldSearch.setName("JTextFieldSearch"); // NOI18N
        JTextFieldSearch.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                JTextFieldSearchKeyReleased(evt);
            }
        });
        jPanel12.add(JTextFieldSearch, java.awt.BorderLayout.CENTER);

        jPanel9.add(jPanel12, java.awt.BorderLayout.CENTER);

        jPanel7.add(jPanel9);

        jPanel10.setName("jPanel10"); // NOI18N
        jPanel10.setLayout(new java.awt.BorderLayout());

        jPanel13.setMaximumSize(new java.awt.Dimension(25, 25));
        jPanel13.setMinimumSize(new java.awt.Dimension(25, 25));
        jPanel13.setName("jPanel13"); // NOI18N
        jPanel13.setPreferredSize(new java.awt.Dimension(60, 25));
        jPanel13.setLayout(new java.awt.BorderLayout());

        buttonGroup1.add(JRadioButtonID);
        JRadioButtonID.setSelected(true);
        JRadioButtonID.setText(resourceMap.getString("JRadioButtonID.text")); // NOI18N
        JRadioButtonID.setName("JRadioButtonID"); // NOI18N
        jPanel13.add(JRadioButtonID, java.awt.BorderLayout.CENTER);

        jPanel10.add(jPanel13, java.awt.BorderLayout.LINE_START);

        jPanel14.setName("jPanel14"); // NOI18N
        jPanel14.setLayout(new java.awt.BorderLayout());

        jPanel15.setName("jPanel15"); // NOI18N
        jPanel15.setPreferredSize(new java.awt.Dimension(65, 25));
        jPanel15.setLayout(new java.awt.BorderLayout());

        buttonGroup1.add(jRadioButtonName);
        jRadioButtonName.setText(resourceMap.getString("jRadioButtonName.text")); // NOI18N
        jRadioButtonName.setName("jRadioButtonName"); // NOI18N
        jRadioButtonName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonNameActionPerformed(evt);
            }
        });
        jPanel15.add(jRadioButtonName, java.awt.BorderLayout.CENTER);

        jPanel14.add(jPanel15, java.awt.BorderLayout.LINE_START);

        jPanel16.setName("jPanel16"); // NOI18N
        jPanel16.setLayout(new java.awt.BorderLayout(5, 0));

        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new java.awt.BorderLayout());

        buttonGroup1.add(jRadioButtonDepart);
        jRadioButtonDepart.setText(resourceMap.getString("jRadioButtonDepart.text")); // NOI18N
        jRadioButtonDepart.setName("jRadioButtonDepart"); // NOI18N
        jPanel2.add(jRadioButtonDepart, java.awt.BorderLayout.CENTER);

        jPanel16.add(jPanel2, java.awt.BorderLayout.LINE_START);

        jPanel28.setName("jPanel28"); // NOI18N
        jPanel28.setLayout(new java.awt.BorderLayout());

        jPanel29.setName("jPanel29"); // NOI18N
        jPanel29.setPreferredSize(new java.awt.Dimension(200, 0));
        jPanel29.setLayout(new java.awt.BorderLayout());

        jLabelNamDepartment.setFont(resourceMap.getFont("jLabelNamDepartment.font")); // NOI18N
        jLabelNamDepartment.setForeground(resourceMap.getColor("jLabelNamDepartment.foreground")); // NOI18N
        jLabelNamDepartment.setText(resourceMap.getString("jLabelNamDepartment.text")); // NOI18N
        jLabelNamDepartment.setName("jLabelNamDepartment"); // NOI18N
        jPanel29.add(jLabelNamDepartment, java.awt.BorderLayout.CENTER);

        jPanel28.add(jPanel29, java.awt.BorderLayout.LINE_START);

        jPanel30.setName("jPanel30"); // NOI18N
        jPanel30.setPreferredSize(new java.awt.Dimension(118, 40));
        jPanel30.setLayout(new java.awt.BorderLayout());

        jButtonReset.setIcon(resourceMap.getIcon("jButtonReset.icon")); // NOI18N
        jButtonReset.setText(resourceMap.getString("jButtonReset.text")); // NOI18N
        jButtonReset.setName("jButtonReset"); // NOI18N
        jButtonReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonResetActionPerformed(evt);
            }
        });
        jPanel30.add(jButtonReset, java.awt.BorderLayout.CENTER);

        jPanel28.add(jPanel30, java.awt.BorderLayout.CENTER);

        jPanel16.add(jPanel28, java.awt.BorderLayout.CENTER);

        jPanel14.add(jPanel16, java.awt.BorderLayout.CENTER);

        jPanel10.add(jPanel14, java.awt.BorderLayout.CENTER);

        jPanel7.add(jPanel10);

        jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER);

        jPanel8.setName("jPanel8"); // NOI18N
        jPanel8.setPreferredSize(new java.awt.Dimension(430, 100));

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 430, Short.MAX_VALUE)
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 90, Short.MAX_VALUE)
        );

        jPanel5.add(jPanel8, java.awt.BorderLayout.LINE_END);

        jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START);

        jPanel6.setMinimumSize(new java.awt.Dimension(495, 170));
        jPanel6.setName("jPanel6"); // NOI18N
        jPanel6.setPreferredSize(new java.awt.Dimension(853, 170));
        jPanel6.setLayout(new java.awt.BorderLayout(0, 5));

        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel17.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel17.border.titleFont"), resourceMap.getColor("jPanel17.border.titleColor"))); // NOI18N
        jPanel17.setName("jPanel17"); // NOI18N
        jPanel17.setLayout(new java.awt.BorderLayout());

        jPanel21.setName("jPanel21"); // NOI18N
        jPanel21.setPreferredSize(new java.awt.Dimension(950, 5));

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 939, Short.MAX_VALUE)
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 5, Short.MAX_VALUE)
        );

        jPanel17.add(jPanel21, java.awt.BorderLayout.PAGE_START);

        jPanel22.setName("jPanel22"); // NOI18N
        jPanel22.setPreferredSize(new java.awt.Dimension(950, 5));

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 939, Short.MAX_VALUE)
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 5, Short.MAX_VALUE)
        );

        jPanel17.add(jPanel22, java.awt.BorderLayout.PAGE_END);

        jPanel23.setMinimumSize(new java.awt.Dimension(0, 100));
        jPanel23.setName("jPanel23"); // NOI18N
        jPanel23.setPreferredSize(new java.awt.Dimension(0, 310));

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 209, Short.MAX_VALUE)
        );

        jPanel17.add(jPanel23, java.awt.BorderLayout.LINE_START);

        jPanel24.setName("jPanel24"); // NOI18N
        jPanel24.setPreferredSize(new java.awt.Dimension(0, 310));

        javax.swing.GroupLayout jPanel24Layout = new javax.swing.GroupLayout(jPanel24);
        jPanel24.setLayout(jPanel24Layout);
        jPanel24Layout.setHorizontalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel24Layout.setVerticalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 209, Short.MAX_VALUE)
        );

        jPanel17.add(jPanel24, java.awt.BorderLayout.LINE_END);

        jPanel25.setName("jPanel25"); // NOI18N
        jPanel25.setLayout(new java.awt.BorderLayout());

        jPanel_____Left.setName("jPanel_____Left"); // NOI18N
        jPanel_____Left.setPreferredSize(new java.awt.Dimension(440, 310));
        jPanel_____Left.setLayout(new java.awt.BorderLayout());

        jPanel33.setName("jPanel33"); // NOI18N
        jPanel33.setPreferredSize(new java.awt.Dimension(90, 30));
        jPanel33.setLayout(new java.awt.GridLayout(9, 1));

        lblId.setText(resourceMap.getString("lblId.text")); // NOI18N
        lblId.setName("lblId"); // NOI18N
        jPanel33.add(lblId);

        q.setName("q"); // NOI18N
        jPanel33.add(q);

        lblName.setText(resourceMap.getString("lblName.text")); // NOI18N
        lblName.setName("lblName"); // NOI18N
        jPanel33.add(lblName);

        w.setName("w"); // NOI18N
        jPanel33.add(w);

        lblAddress.setText(resourceMap.getString("lblAddress.text")); // NOI18N
        lblAddress.setName("lblAddress"); // NOI18N
        jPanel33.add(lblAddress);

        e.setName("e"); // NOI18N
        jPanel33.add(e);

        lblPhone.setText(resourceMap.getString("lblPhone.text")); // NOI18N
        lblPhone.setName("lblPhone"); // NOI18N
        jPanel33.add(lblPhone);

        v.setName("v"); // NOI18N
        jPanel33.add(v);

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N
        jPanel33.add(jLabel5);

        jPanel_____Left.add(jPanel33, java.awt.BorderLayout.LINE_START);

        jPanel34.setName("jPanel34"); // NOI18N
        jPanel34.setLayout(new java.awt.GridLayout(9, 1));

        jTextFieldID.setEditable(false);
        jTextFieldID.setName("jTextFieldID"); // NOI18N
        jPanel34.add(jTextFieldID);

        l.setFont(resourceMap.getFont("l.font")); // NOI18N
        l.setForeground(resourceMap.getColor("l.foreground")); // NOI18N
        l.setName("l"); // NOI18N
        jPanel34.add(l);

        jTextFieldName.setName("jTextFieldName"); // NOI18N
        jPanel34.add(jTextFieldName);

        jLabelName.setFont(resourceMap.getFont("jLabelName.font")); // NOI18N
        jLabelName.setForeground(resourceMap.getColor("jLabelName.foreground")); // NOI18N
        jLabelName.setName("jLabelName"); // NOI18N
        jPanel34.add(jLabelName);

        jTextFieldAddress.setName("jTextFieldAddress"); // NOI18N
        jPanel34.add(jTextFieldAddress);

        jLabelAdress.setFont(resourceMap.getFont("jLabelAdress.font")); // NOI18N
        jLabelAdress.setForeground(resourceMap.getColor("jLabelAdress.foreground")); // NOI18N
        jLabelAdress.setName("jLabelAdress"); // NOI18N
        jPanel34.add(jLabelAdress);

        jTextFieldPhone.setName("jTextFieldPhone"); // NOI18N
        jPanel34.add(jTextFieldPhone);

        jLabelPhone.setFont(resourceMap.getFont("jLabelPhone.font")); // NOI18N
        jLabelPhone.setForeground(resourceMap.getColor("jLabelPhone.foreground")); // NOI18N
        jLabelPhone.setName("jLabelPhone"); // NOI18N
        jPanel34.add(jLabelPhone);

        jPanel35.setName("jPanel35"); // NOI18N
        jPanel35.setLayout(new java.awt.BorderLayout());

        jPanel36.setName("jPanel36"); // NOI18N
        jPanel36.setPreferredSize(new java.awt.Dimension(80, 58));
        jPanel36.setLayout(new java.awt.BorderLayout());

        jComboBoxSex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Male", "Female" }));
        jComboBoxSex.setName("jComboBoxSex"); // NOI18N
        jPanel36.add(jComboBoxSex, java.awt.BorderLayout.CENTER);

        jPanel35.add(jPanel36, java.awt.BorderLayout.LINE_START);

        jPanel37.setName("jPanel37"); // NOI18N

        javax.swing.GroupLayout jPanel37Layout = new javax.swing.GroupLayout(jPanel37);
        jPanel37.setLayout(jPanel37Layout);
        jPanel37Layout.setHorizontalGroup(
            jPanel37Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 170, Short.MAX_VALUE)
        );
        jPanel37Layout.setVerticalGroup(
            jPanel37Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 23, Short.MAX_VALUE)
        );

        jPanel35.add(jPanel37, java.awt.BorderLayout.CENTER);

        jPanel34.add(jPanel35);

        jPanel_____Left.add(jPanel34, java.awt.BorderLayout.CENTER);

        jPanel40.setName("jPanel40"); // NOI18N
        jPanel40.setPreferredSize(new java.awt.Dimension(100, 30));
        jPanel40.setLayout(new java.awt.GridLayout(5, 1, 0, 5));
        jPanel_____Left.add(jPanel40, java.awt.BorderLayout.LINE_END);

        jPanel25.add(jPanel_____Left, java.awt.BorderLayout.LINE_START);

        jPanel______Right.setName("jPanel______Right"); // NOI18N
        jPanel______Right.setLayout(new java.awt.BorderLayout());

        jPanel27.setName("jPanel27"); // NOI18N
        jPanel27.setPreferredSize(new java.awt.Dimension(400, 310));
        jPanel27.setLayout(new java.awt.BorderLayout());

        jPanel38.setName("jPanel38"); // NOI18N
        jPanel38.setPreferredSize(new java.awt.Dimension(225, 130));
        jPanel38.setLayout(new java.awt.BorderLayout());

        jPanel39.setName("jPanel39"); // NOI18N
        jPanel39.setPreferredSize(new java.awt.Dimension(100, 100));
        jPanel39.setLayout(new java.awt.GridLayout(9, 1));

        lblStatus.setText(resourceMap.getString("lblStatus.text")); // NOI18N
        lblStatus.setName("lblStatus"); // NOI18N
        jPanel39.add(lblStatus);

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N
        jPanel39.add(jLabel10);

        lblUsername.setText(resourceMap.getString("lblUsername.text")); // NOI18N
        lblUsername.setName("lblUsername"); // NOI18N
        jPanel39.add(lblUsername);

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N
        jPanel39.add(jLabel9);

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N
        jPanel39.add(jLabel8);

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N
        jPanel39.add(jLabel6);

        lblEmail.setText(resourceMap.getString("lblEmail.text")); // NOI18N
        lblEmail.setName("lblEmail"); // NOI18N
        jPanel39.add(lblEmail);

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N
        jPanel39.add(jLabel7);

        lblStaff.setText(resourceMap.getString("lblStaff.text")); // NOI18N
        lblStaff.setName("lblStaff"); // NOI18N
        jPanel39.add(lblStaff);

        jPanel38.add(jPanel39, java.awt.BorderLayout.LINE_START);

        jPanel41.setName("jPanel41"); // NOI18N
        jPanel41.setLayout(new java.awt.GridLayout(9, 1));

        jPanel42.setName("jPanel42"); // NOI18N
        jPanel42.setLayout(new java.awt.GridLayout(1, 3, 10, 0));

        jComboBoxngay.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        jComboBoxngay.setName("jComboBoxngay"); // NOI18N
        jPanel42.add(jComboBoxngay);

        jComboBoxThang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));
        jComboBoxThang.setName("jComboBoxThang"); // NOI18N
        jPanel42.add(jComboBoxThang);

        jComboBoxNam.setName("jComboBoxNam"); // NOI18N
        jPanel42.add(jComboBoxNam);

        jPanel41.add(jPanel42);

        jLabelBrithday.setFont(resourceMap.getFont("jLabelBrithday.font")); // NOI18N
        jLabelBrithday.setForeground(resourceMap.getColor("jLabelBrithday.foreground")); // NOI18N
        jLabelBrithday.setName("jLabelBrithday"); // NOI18N
        jPanel41.add(jLabelBrithday);

        jTextFieldUserName.setName("jTextFieldUserName"); // NOI18N
        jPanel41.add(jTextFieldUserName);

        jLabelUsername.setFont(resourceMap.getFont("jLabelUsername.font")); // NOI18N
        jLabelUsername.setForeground(resourceMap.getColor("jLabelUsername.foreground")); // NOI18N
        jLabelUsername.setName("jLabelUsername"); // NOI18N
        jPanel41.add(jLabelUsername);

        jPasswordFieldPassword.setName("jPasswordFieldPassword"); // NOI18N
        jPanel41.add(jPasswordFieldPassword);

        jLabelPassword.setFont(resourceMap.getFont("jLabelPassword.font")); // NOI18N
        jLabelPassword.setForeground(resourceMap.getColor("jLabelPassword.foreground")); // NOI18N
        jLabelPassword.setName("jLabelPassword"); // NOI18N
        jPanel41.add(jLabelPassword);

        jTextFieldEmail.setName("jTextFieldEmail"); // NOI18N
        jPanel41.add(jTextFieldEmail);

        jLabelEmail.setFont(resourceMap.getFont("jLabelEmail.font")); // NOI18N
        jLabelEmail.setForeground(resourceMap.getColor("jLabelEmail.foreground")); // NOI18N
        jLabelEmail.setName("jLabelEmail"); // NOI18N
        jPanel41.add(jLabelEmail);

        jComboBoxDepart.setName("jComboBoxDepart"); // NOI18N
        jPanel41.add(jComboBoxDepart);

        jPanel38.add(jPanel41, java.awt.BorderLayout.CENTER);

        jPanel27.add(jPanel38, java.awt.BorderLayout.CENTER);

        jPanel45.setMinimumSize(new java.awt.Dimension(50, 20));
        jPanel45.setName("jPanel45"); // NOI18N
        jPanel45.setPreferredSize(new java.awt.Dimension(50, 281));
        jPanel45.setLayout(new java.awt.GridLayout(5, 1, 0, 5));
        jPanel27.add(jPanel45, java.awt.BorderLayout.LINE_END);

        jPanel______Right.add(jPanel27, java.awt.BorderLayout.LINE_START);

        jPanel32.setName("jPanel32"); // NOI18N
        jPanel32.setPreferredSize(new java.awt.Dimension(120, 174));
        jPanel32.setLayout(new java.awt.GridLayout(4, 1, 0, 30));

        btnAdd.setIcon(resourceMap.getIcon("btnAdd.icon")); // NOI18N
        btnAdd.setText(resourceMap.getString("btnAdd.text")); // NOI18N
        btnAdd.setName("btnAdd"); // NOI18N
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });
        jPanel32.add(btnAdd);

        btnUpdate.setIcon(resourceMap.getIcon("btnUpdate.icon")); // NOI18N
        btnUpdate.setText(resourceMap.getString("btnUpdate.text")); // NOI18N
        btnUpdate.setName("btnUpdate"); // NOI18N
        btnUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdateActionPerformed(evt);
            }
        });
        jPanel32.add(btnUpdate);

        btnDelete.setIcon(resourceMap.getIcon("btnDelete.icon")); // NOI18N
        btnDelete.setText(resourceMap.getString("btnDelete.text")); // NOI18N
        btnDelete.setName("btnDelete"); // NOI18N
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });
        jPanel32.add(btnDelete);

        btnDelete1.setIcon(resourceMap.getIcon("btnDelete1.icon")); // NOI18N
        btnDelete1.setText(resourceMap.getString("btnDelete1.text")); // NOI18N
        btnDelete1.setName("btnDelete1"); // NOI18N
        btnDelete1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDelete1ActionPerformed(evt);
            }
        });
        jPanel32.add(btnDelete1);

        jPanel______Right.add(jPanel32, java.awt.BorderLayout.CENTER);

        jPanel25.add(jPanel______Right, java.awt.BorderLayout.CENTER);

        jPanel17.add(jPanel25, java.awt.BorderLayout.CENTER);

        jPanel6.add(jPanel17, java.awt.BorderLayout.CENTER);

        jPanel19.setMinimumSize(new java.awt.Dimension(550, 10));
        jPanel19.setName("jPanel19"); // NOI18N
        jPanel19.setPreferredSize(new java.awt.Dimension(853, 0));

        javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19);
        jPanel19.setLayout(jPanel19Layout);
        jPanel19Layout.setHorizontalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 951, Short.MAX_VALUE)
        );
        jPanel19Layout.setVerticalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jPanel6.add(jPanel19, java.awt.BorderLayout.PAGE_END);

        jPanel3.add(jPanel6, java.awt.BorderLayout.CENTER);

        jPanel1.add(jPanel3, java.awt.BorderLayout.CENTER);

        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setPreferredSize(new java.awt.Dimension(250, 170));
        jPanel4.setLayout(new java.awt.BorderLayout());

        jScrollPane1.setName("jScrollPane1"); // NOI18N
        jScrollPane1.setPreferredSize(new java.awt.Dimension(600, 200));

        jTable1.setAutoscrolls(false);
        jTable1.setName("jTable1"); // NOI18N
        jTable1.setPreferredSize(new java.awt.Dimension(600, 240));
        jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jTable1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTable1KeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTable1KeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel1.add(jPanel4, java.awt.BorderLayout.PAGE_END);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        jLabel1.setName("jLabel1"); // NOI18N
        jLabel1.setPreferredSize(new java.awt.Dimension(0, 10));
        getContentPane().add(jLabel1, java.awt.BorderLayout.PAGE_START);

        jLabel2.setName("jLabel2"); // NOI18N
        jLabel2.setPreferredSize(new java.awt.Dimension(10, 0));
        getContentPane().add(jLabel2, java.awt.BorderLayout.LINE_START);

        jLabel3.setName("jLabel3"); // NOI18N
        jLabel3.setPreferredSize(new java.awt.Dimension(0, 10));
        getContentPane().add(jLabel3, java.awt.BorderLayout.PAGE_END);

        jLabel4.setName("jLabel4"); // NOI18N
        jLabel4.setPreferredSize(new java.awt.Dimension(10, 0));
        getContentPane().add(jLabel4, java.awt.BorderLayout.LINE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // TODO add your handling code here:
        try {
            Display();
            this.jLabelBrithday.setText("");
            this.jLabelUsername.setText("");
            this.jLabelName.setText("");
            this.jLabelAdress.setText("");
            this.jLabelPhone.setText("");
            this.jLabelPassword.setText("");
            this.jLabelEmail.setText("");
        } catch (Exception e) {
        }

    }//GEN-LAST:event_jTable1MouseClicked

    private void JTextFieldSearchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_JTextFieldSearchKeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_JTextFieldSearchKeyReleased

    private void jRadioButtonNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonNameActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jRadioButtonNameActionPerformed

    private void jButtonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSearchActionPerformed


        // TODO add your handling code here:
        this.jLabelNamDepartment.setText("");
        if (JTextFieldSearch.getText().trim().length() == 0) {
            JOptionPane.showMessageDialog(null, rb.getString("InputText"));
        } else {
            if (jRadioButtonName.isSelected() == false && JRadioButtonID.isSelected() == false && jRadioButtonDepart.isSelected() == false) {
                JOptionPane.showMessageDialog(null, rb.getString("ChooseIdName"));
                DisplayTableNull();;
                return;
            } else {
                if (JRadioButtonID.isSelected() == true) {
                    if (CommonQuery.CheckIntNumber(JTextFieldSearch.getText()) == false) {
                        JOptionPane.showMessageDialog(null, rb.getString("InputNumberNotString"));
                    } else if (Employee.ListIDONID(Integer.parseInt(JTextFieldSearch.getText())).size() == 0) {
                        JOptionPane.showMessageDialog(null, rb.getString("CantFindID"));
                        DisplayTableNull();;
                        return;
                    } else {
                        DisplayTable(Employee.ListIDONID(Integer.parseInt(JTextFieldSearch.getText())));
                    }
                }
                if (jRadioButtonName.isSelected() == true) {
                    if (Employee.ListIDEONNAMEEMP(JTextFieldSearch.getText().toString().trim()).size() == 0) {
                        JOptionPane.showMessageDialog(null, rb.getString("CantFindName"));
                        DisplayTableNull();;
                        return;
                    }
                    DisplayTable(Employee.ListIDEONNAMEEMP(JTextFieldSearch.getText().toString().trim()));
                }
                if (jRadioButtonDepart.isSelected() == true) {
                    if (CommonQuery.CheckIntNumber(JTextFieldSearch.getText()) == false) {
                        JOptionPane.showMessageDialog(null, rb.getString("InputNumberNotString"));
                    } else if (Employee.ListIDEONIDDEPART(Integer.parseInt(JTextFieldSearch.getText())).size() == 0) {
                        JOptionPane.showMessageDialog(null, rb.getString("CantFindID"));
                        DisplayTableNull();;
                        return;
                    } else {

                        String namedepartment = Employee.NameDepartment(Integer.parseInt(this.JTextFieldSearch.getText()));
                        //JOptionPane.showMessageDialog(null, namedepartment);
                        this.jLabelNamDepartment.setText(namedepartment);

                        DisplayTable(Employee.ListIDEONIDDEPART(Integer.parseInt(JTextFieldSearch.getText())));
                    }

                }
            }
        }
}//GEN-LAST:event_jButtonSearchActionPerformed

    private void jButtonResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonResetActionPerformed
        // TODO add your handling code here:
        r = -1;
        this.jTextFieldName.setText("");
        this.jTextFieldEmail.setText("");
        this.jTextFieldPhone.setText("");
        this.jTextFieldUserName.setText("");
        this.jTextFieldAddress.setText("");
        this.jPasswordFieldPassword.setText("");
        this.jLabelBrithday.setText("");
        this.jLabelUsername.setText("");
        this.jLabelName.setText("");
        this.jLabelAdress.setText("");
        this.jLabelPhone.setText("");
        this.jLabelPassword.setText("");
        this.jLabelEmail.setText("");
        this.jTextFieldID.setText("");
        jPasswordFieldPassword.setEnabled(true);
        jComboBoxDepart.setEnabled(true);
        idem = -1;
        DisplayTable(Employee.ListIDE());
    }//GEN-LAST:event_jButtonResetActionPerformed

    private void jTable1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyPressed
    }//GEN-LAST:event_jTable1KeyPressed

    private void jTable1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyReleased
        try {
            Display();
            this.jLabelBrithday.setText("");
            this.jLabelUsername.setText("");
            this.jLabelName.setText("");
            this.jLabelAdress.setText("");
            this.jLabelPhone.setText("");
            this.jLabelPassword.setText("");
            this.jLabelEmail.setText("");
        } catch (Exception e) {
        }
    }//GEN-LAST:event_jTable1KeyReleased

    private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
        String month = jComboBoxThang.getSelectedItem().toString();
        String day = jComboBoxngay.getSelectedItem().toString();
        String pass = convertPassword(this.jPasswordFieldPassword.getPassword());
        if (GetSource()) {
            if (!CheckUsername(this.jTextFieldUserName.getText())) {
                this.jLabelUsername.setText(rb.getString("UserNameExist"));
                this.jLabelName.setText("");
                this.jLabelAdress.setText("");
                this.jLabelPhone.setText("");
                this.jLabelBrithday.setText("");
                this.jLabelPassword.setText("");
                this.jLabelEmail.setText("");
            } else if (!CommonQuery.CheckString(pass)) {
                this.jLabelPassword.setText(rb.getString("InputPass"));
                this.jLabelUsername.setText("");
                this.jLabelName.setText("");
                this.jLabelAdress.setText("");
                this.jLabelPhone.setText("");
                this.jLabelBrithday.setText("");
                this.jLabelEmail.setText("");
            } else {
                if (CheckDate() == false) {
                    this.jLabelBrithday.setText(rb.getString("Month") + month + rb.getString("DontHaveDay") + day);
                    this.jLabelUsername.setText("");
                    this.jLabelName.setText("");
                    this.jLabelAdress.setText("");
                    this.jLabelPhone.setText("");
                    this.jLabelPassword.setText("");
                    this.jLabelEmail.setText("");
                    return;
                } else {
                    if (CanculateAge() < 18) {
                        this.jLabelBrithday.setText(rb.getString("EmployeeAge"));
                        this.jLabelUsername.setText("");
                        this.jLabelName.setText("");
                        this.jLabelAdress.setText("");
                        this.jLabelPhone.setText("");
                        this.jLabelPassword.setText("");
                        this.jLabelEmail.setText("");
                        return;
                    } else {

                        ep.setPassword(pass);
                        if (ep.AddEmployee() == true) {
                            JOptionPane.showMessageDialog(null, rb.getString("AddSuccess"));
                            EncryptionPasswordAdd();
                            this.jLabelBrithday.setText("");
                            this.jLabelUsername.setText("");
                            this.jLabelName.setText("");
                            this.jLabelAdress.setText("");
                            this.jLabelPhone.setText("");
                            this.jLabelPassword.setText("");
                            this.jLabelEmail.setText("");
                        } else {
                            JOptionPane.showMessageDialog(null, rb.getString("AddFail"));
                            this.jLabelBrithday.setText("");
                            this.jLabelUsername.setText("");
                            this.jLabelName.setText("");
                            this.jLabelAdress.setText("");
                            this.jLabelPhone.setText("");
                            this.jLabelPassword.setText("");
                            this.jLabelEmail.setText("");
                        }
                    }
                    DisplayTable(Employee.ListIDE());
                    this.jTextFieldName.setText("");
                    this.jTextFieldEmail.setText("");
                    this.jTextFieldPhone.setText("");
                    this.jTextFieldUserName.setText("");
                    this.jTextFieldAddress.setText("");
                    this.jPasswordFieldPassword.setText("");
                }
            }
        }
}//GEN-LAST:event_btnAddActionPerformed

    private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateActionPerformed


        jComboBoxDepart.setEnabled(true);
        String month = jComboBoxThang.getSelectedItem().toString();
        String day = jComboBoxngay.getSelectedItem().toString();
        if (r < 0) {
            JOptionPane.showMessageDialog(null, rb.getString("ChooseEmployeeUpdate"));
        } else {
            if (GetSource()) {
                String pass = EncryptionPasswordUpdate(idem);
                ep.setIdemployee(idem);

                if (CheckDate() == false) {
                    this.jLabelBrithday.setText(rb.getString("Month") + month + rb.getString("DontHaveDay") + day);
                    this.jLabelUsername.setText("");
                    this.jLabelName.setText("");
                    this.jLabelAdress.setText("");
                    this.jLabelPhone.setText("");
                    this.jLabelPassword.setText("");
                    this.jLabelEmail.setText("");
                } else {
                    if (CanculateAge() < 18) {
                        this.jLabelBrithday.setText(rb.getString("EmployeeAge"));
                        this.jLabelUsername.setText("");
                        this.jLabelName.setText("");
                        this.jLabelAdress.setText("");
                        this.jLabelPhone.setText("");
                        this.jLabelPassword.setText("");
                        this.jLabelEmail.setText("");
                        return;
                    } else {
                        if (!CommonQuery.CheckString(pass)) {
                            pass = AddPassE(idem);
                        }
                        ep.setPassword(pass);
                        if (ep.UpdateEmployee() == true) {
                            JOptionPane.showMessageDialog(null, rb.getString("UpdateSuccess"));
                            this.jLabelBrithday.setText("");
                            this.jLabelUsername.setText("");
                            this.jLabelName.setText("");
                            this.jLabelAdress.setText("");
                            this.jLabelPhone.setText("");
                            this.jLabelPassword.setText("");
                            this.jLabelEmail.setText("");
                            jTextFieldID.setText("");
                            r = -1;
                            DisplayTable(Employee.ListIDONID(idem));
                        } else {
                            JOptionPane.showMessageDialog(null, rb.getString("UpdateFail"));
                            this.jLabelBrithday.setText("");
                            this.jLabelUsername.setText("");
                            this.jLabelName.setText("");
                            this.jLabelAdress.setText("");
                            this.jLabelPhone.setText("");
                            this.jLabelPassword.setText("");
                            this.jLabelEmail.setText("");
                        }
                    }

                    this.jTextFieldName.setText("");
                    this.jTextFieldEmail.setText("");
                    this.jTextFieldPhone.setText("");
                    this.jTextFieldUserName.setText("");
                    this.jTextFieldAddress.setText("");
                    this.jPasswordFieldPassword.setText("");
                }
            }
        }

    }//GEN-LAST:event_btnUpdateActionPerformed

    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
        this.jTextFieldName.setText("");
        this.jTextFieldEmail.setText("");
        this.jTextFieldPhone.setText("");
        this.jTextFieldUserName.setText("");
        this.jTextFieldAddress.setText("");
        this.jPasswordFieldPassword.setText("");
        this.jLabelBrithday.setText("");
        this.jLabelUsername.setText("");
        this.jLabelName.setText("");
        this.jLabelAdress.setText("");
        this.jLabelPhone.setText("");
        this.jLabelPassword.setText("");
        this.jLabelEmail.setText("");



}//GEN-LAST:event_btnDeleteActionPerformed

    private void btnDelete1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDelete1ActionPerformed
        // TODO add your handling code here
        if (r < 0) {
            JOptionPane.showMessageDialog(null, rb.getString("ChooseEmployeeDelete"));
        } else {

            ep.setIdemployee(idem);
            if (iddepart == 1) {
                JOptionPane.showMessageDialog(null, rb.getString("AdminCantDelete"));
            } else if (ep.DeleteEmployee() == true) {
                JOptionPane.showMessageDialog(null, rb.getString("DeleteSuccess"));
                DeleteSkey(idem);
                this.jTextFieldName.setText("");
                this.jTextFieldEmail.setText("");
                this.jTextFieldPhone.setText("");
                this.jTextFieldUserName.setText("");
                this.jTextFieldAddress.setText("");
                this.jPasswordFieldPassword.setText("");
                this.jLabelBrithday.setText("");
                this.jLabelUsername.setText("");
                this.jLabelName.setText("");
                this.jLabelAdress.setText("");
                this.jLabelPhone.setText("");
                this.jLabelPassword.setText("");
                this.jLabelEmail.setText("");
                r = -1;
            } else {
                JOptionPane.showMessageDialog(null, rb.getString("EmployeeisUsed"));
            }
        }
        DisplayTable(Employee.ListIDE());


    }//GEN-LAST:event_btnDelete1ActionPerformed

    private void DeleteSkey(int ide) {
        File f = new File("SecretKey/skey" + ide);
        f.delete();
    }

    private String EncryptionPasswordUpdate(int id) {
        String pass = convertPassword(this.jPasswordFieldPassword.getPassword());
        CommonQuery com = new CommonQuery();
        String password = "";
        if (CommonQuery.CheckString(pass)) {
            password = com.Encrypt(pass, id);
        }
        return password;
    }

    private void EncryptionPasswordAdd() {
        String pass = "";
        CommonQuery com = new CommonQuery();
        Vector<Employee> listide = Employee.ListIDE();
        for (Employee e : listide) {
            int ide = Employee.LastID();
            if (e.getIdemployee() == ide) {
                pass = e.getPassword();
                pass = com.Encrypt(pass, ide);
                e.setIdemployee(ide);
                e.setPassword(pass);
                e.ChangePassword();
            }
        }
    }

    private String AddPassE(int idem) {
        String pass = "";
        Vector<Employee> listide = Employee.ListIDE();
        for (Employee e : listide) {
            if (idem == e.getIdemployee()) {
                pass = e.getPassword();
            }
        }
        return pass;
    }

    private boolean GetSource() {

        int index = jComboBoxDepart.getSelectedIndex();
        Date birth = new Date();
        try {
            String birthday = this.jComboBoxNam.getSelectedItem().toString() + "-" + this.jComboBoxThang.getSelectedItem().toString() + "-" + this.jComboBoxngay.getSelectedItem().toString();
            SimpleDateFormat spf = new SimpleDateFormat("yyyy-MM-dd");
            spf.setLenient(false);
            birth = spf.parse(birthday);;
        } catch (Exception ex) {
        }

        java.sql.Date birth1 = new java.sql.Date(birth.getTime());
        //String pass= convertPassword(jPasswordFieldPassword.getPassword());
        ep.setBirthday(birth1);
        if (jTextFieldName.getText().toString().length() == 0) {
            this.jLabelName.setText(rb.getString("InputName"));
            this.jLabelAdress.setText("");
            this.jLabelPhone.setText("");
            this.jLabelBrithday.setText("");
            this.jLabelUsername.setText("");
            this.jLabelPassword.setText("");
            this.jLabelEmail.setText("");
            return false;
        } else if (jTextFieldAddress.getText().toString().length() == 0) {
            this.jLabelName.setText("");
            this.jLabelAdress.setText(rb.getString("InputAddress"));
            this.jLabelPhone.setText("");
            this.jLabelBrithday.setText("");
            this.jLabelUsername.setText("");
            this.jLabelPassword.setText("");
            this.jLabelEmail.setText("");
            return false;
        } else if (jTextFieldPhone.getText().toString().length() == 0) {
            this.jLabelName.setText("");
            this.jLabelAdress.setText("");
            this.jLabelPhone.setText(rb.getString("InputPhone"));
            this.jLabelBrithday.setText("");
            this.jLabelUsername.setText("");
            this.jLabelPassword.setText("");
            this.jLabelEmail.setText("");
            return false;
        } else if (CommonQuery.CheckPhone(jTextFieldPhone.getText()) == false) {
            this.jLabelName.setText("");
            this.jLabelAdress.setText("");
            this.jLabelPhone.setText(rb.getString("PhoneWrong"));
            this.jLabelBrithday.setText("");
            this.jLabelUsername.setText("");
            this.jLabelPassword.setText("");
            this.jLabelEmail.setText("");
            return false;
        } else if (jTextFieldUserName.getText().toString().trim().length() == 0) {
            this.jLabelName.setText("");
            this.jLabelAdress.setText("");
            this.jLabelPhone.setText("");
            this.jLabelBrithday.setText("");
            this.jLabelUsername.setText(rb.getString("InputUserName"));
            this.jLabelPassword.setText("");
            this.jLabelEmail.setText("");
            return false;
        } else if (jTextFieldEmail.getText().toString().length() == 0) {
            this.jLabelName.setText("");
            this.jLabelAdress.setText("");
            this.jLabelPhone.setText("");
            this.jLabelBrithday.setText("");
            this.jLabelUsername.setText("");
            this.jLabelPassword.setText("");
            this.jLabelEmail.setText(rb.getString("InputEmail"));
            return false;
        } else if (CommonQuery.CheckEmail(jTextFieldEmail.getText().toString()) == false) {
            this.jLabelName.setText("");
            this.jLabelAdress.setText("");
            this.jLabelPhone.setText("");
            this.jLabelBrithday.setText("");
            this.jLabelUsername.setText("");
            this.jLabelPassword.setText("");
            this.jLabelEmail.setText(rb.getString("EmailWrong"));
            return false;
        } else {
            ep.setUsername(jTextFieldUserName.getText().toString().trim());
            ep.setIddepartment(valueRl.get(index));
            ep.setEmailaddress(jTextFieldEmail.getText());
            ep.setHomeaddress(jTextFieldAddress.getText());
            ep.setNameemployee(jTextFieldName.getText());
            ep.setSex(jComboBoxSex.getSelectedItem().toString());
            ep.setPhonenumber(jTextFieldPhone.getText());
            return true;
        }
    }

    private boolean CheckUsername(String user) {
        boolean kq = true;
        Vector<Employee> listun = Employee.ListIDE();
        for (Employee e : listun) {
            if (e.getUsername().equals(user)) {
                kq = false;
            }
        }
        return kq;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton JRadioButtonID;
    private javax.swing.JTextField JTextFieldSearch;
    private javax.swing.JButton btnAdd;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnDelete1;
    private javax.swing.JButton btnUpdate;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel e;
    private javax.swing.JButton jButtonReset;
    private javax.swing.JButton jButtonSearch;
    private javax.swing.JComboBox jComboBoxDepart;
    private javax.swing.JComboBox jComboBoxNam;
    private javax.swing.JComboBox jComboBoxSex;
    private javax.swing.JComboBox jComboBoxThang;
    private javax.swing.JComboBox jComboBoxngay;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelAdress;
    private javax.swing.JLabel jLabelBrithday;
    private javax.swing.JLabel jLabelEmail;
    private javax.swing.JLabel jLabelNamDepartment;
    private javax.swing.JLabel jLabelName;
    private javax.swing.JLabel jLabelPassword;
    private javax.swing.JLabel jLabelPhone;
    private javax.swing.JLabel jLabelUsername;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel24;
    private javax.swing.JPanel jPanel25;
    private javax.swing.JPanel jPanel27;
    private javax.swing.JPanel jPanel28;
    private javax.swing.JPanel jPanel29;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel30;
    private javax.swing.JPanel jPanel32;
    private javax.swing.JPanel jPanel33;
    private javax.swing.JPanel jPanel34;
    private javax.swing.JPanel jPanel35;
    private javax.swing.JPanel jPanel36;
    private javax.swing.JPanel jPanel37;
    private javax.swing.JPanel jPanel38;
    private javax.swing.JPanel jPanel39;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel40;
    private javax.swing.JPanel jPanel41;
    private javax.swing.JPanel jPanel42;
    private javax.swing.JPanel jPanel45;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPanel jPanel_____Left;
    private javax.swing.JPanel jPanel______Right;
    private javax.swing.JPasswordField jPasswordFieldPassword;
    private javax.swing.JRadioButton jRadioButtonDepart;
    private javax.swing.JRadioButton jRadioButtonName;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextFieldAddress;
    private javax.swing.JTextField jTextFieldEmail;
    private javax.swing.JTextField jTextFieldID;
    private javax.swing.JTextField jTextFieldName;
    private javax.swing.JTextField jTextFieldPhone;
    private javax.swing.JTextField jTextFieldUserName;
    private javax.swing.JLabel l;
    private javax.swing.JLabel lblAddress;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblId;
    private javax.swing.JLabel lblName;
    private javax.swing.JLabel lblPhone;
    private javax.swing.JLabel lblStaff;
    private javax.swing.JLabel lblStatus;
    private javax.swing.JLabel lblUsername;
    private javax.swing.JLabel q;
    private javax.swing.JLabel v;
    private javax.swing.JLabel w;
    // End of variables declaration//GEN-END:variables
}
